{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import Annotated\n",
    "from typing_extensions import TypedDict\n",
    "from langgraph.graph import StateGraph,START,END\n",
    "from operator import add\n",
    "# {\"foo\":1}\n",
    "\n",
    "\n",
    "class State(TypedDict):\n",
    "    # foo: Annotated[list[int],lambda x,y:x+y]\n",
    "    foo: Annotated[list[int],add]\n",
    "\n",
    "\n",
    "def agent_01(state):\n",
    "    new_state = {\"foo\":[state[\"foo\"][0]+1]}\n",
    "    return new_state\n",
    "\n",
    "_buider = StateGraph(State)\n",
    "\n",
    "_buider.add_node(\"node_01\", agent_01)\n",
    "_buider.add_edge(START,\"node_01\")\n",
    "_buider.add_edge(\"node_01\",END)\n",
    "\n",
    "\n",
    "_graph = _buider.compile()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'foo': [2, 3]}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "_graph.invoke({\"foo\":[2]})"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py310",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
